<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCommodityActivitySkuStatisticsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('commodity_activity_sku_statistics', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('commodity_id')->index('commodity_id')->comment('商品 ID');
            $table->bigInteger('commodity_activity_id')->index('commodity_activity_id')->comment('商品活动 ID');
            $table->bigInteger('commodity_activity_sku_id')->index('commodity_activity_sku_id')->comment('商品活动 SKU ID');

            $table->unsignedInteger('quantity_sold')->default(0)->comment('总卖出数量');
            $table->unsignedInteger('quantity_sold_amount')->default(0)->comment('卖出总成本(成本进价*卖出数量)单位分');
            $table->unsignedInteger('total_returns')->default(0)->comment('退货总数');
            $table->unsignedInteger('total_returns_amount')->default(0)->comment('退货总成本(成本进价*退货数量)单位分');
            $table->unsignedInteger('total_refunds')->default(0)->comment('退款总数');
            $table->unsignedInteger('total_refunds_amount')->default(0)->comment('退款总成本(成本进价*退货数量)单位分');

            $table->unsignedInteger('group_owner_shipments')->default(0)->comment('群主出货量');
            $table->unsignedInteger('group_owner_shipments_amount')->default(0)->comment('群主出货总金额(群主单价*数量)单位分');
            $table->unsignedInteger('group_owner_shipments_purchase_amount')->default(0)->comment('群主出货总成本(进价*数量)单位分');
            $table->unsignedInteger('elite_shipments')->default(0)->comment('精英出货量');
            $table->unsignedInteger('elite_shipments_amount')->default(0)->comment('精英出货总金额(精英单价*数量)单位分');
            $table->unsignedInteger('elite_shipments_purchase_amount')->default(0)->comment('精英出货总成本(进价*数量)单位分');
            $table->unsignedInteger('strongman_shipments')->default(0)->comment('大咖出货量');
            $table->unsignedInteger('strongman_shipments_amount')->default(0)->comment('大咖出货总金额(大咖单价*数量)单位分');
            $table->unsignedInteger('strongman_shipments_purchase_amount')->default(0)->comment('大咖出货总成本(进价*数量)单位分');

            $table->unsignedInteger('number_of_direct_invitations')->default(0)->comment('直接邀请数量');
            $table->unsignedInteger('number_of_direct_invitations_amount')->default(0)->comment('直接邀请总金额(直接邀请单价*数量)单位分');
            $table->unsignedInteger('number_of_indirect_invitations')->default(0)->comment('间接邀请数量');
            $table->unsignedInteger('number_of_indirect_invitations_amount')->default(0)->comment('间接邀请总金额(间接邀请单价*数量)单位分');

            $table->unsignedInteger('number_of_strongman_with_elite_commissions')->default(0)->comment('大咖与精英的佣金数量');
            $table->unsignedInteger('number_of_strongman_with_elite_commissions_amount')->default(0)->comment('大咖与精英的佣金总金额(单价佣金*数量)单位分');
            $table->unsignedInteger('number_of_strongman_with_group_owner_commissions')->default(0)->comment('大咖与群主的佣金数量');
            $table->unsignedInteger('number_of_strongman_with_group_owner_commissions_amount')->default(0)->comment('大咖与群主的佣金总金额(单价佣金*数量)单位分');
            $table->unsignedInteger('number_of_elite_with_group_owner_commissions')->default(0)->comment('精英与群主的佣金数量');
            $table->unsignedInteger('number_of_elite_with_group_owner_commissions_amount')->default(0)->comment('精英与群主的佣金总金额(单价佣金*数量)单位分');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('commodity_activity_sku_statistics');
    }
}
